package com.caigou.bean.es;

import com.caigou.bean.vo.BidVO;
import com.caigou.bean.vo.ItemVO;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;

@Data
@Document(indexName = "bid-alias", type = "bid")
//@Document(indexName = "bid-second", type = "bid")
public class EsBid {
    @Id //主键,注意这个搜索是id类型是string，与我们常用的不同
    private String id;//@Id注解加上后，在Elasticsearch里相应于该列就是主键了，在查询时就可以直接用主键查询

//    @MultiField(
//            mainField = @Field(type = FieldType.Keyword),
//            otherFields = {
//                    @InnerField(type = FieldType.Text, suffix="ik", analyzer = "ik_max_word", searchAnalyzer="ik_smart"),
//                    @InnerField(type = FieldType.Text, suffix="pinyin", analyzer = "pinyin", searchAnalyzer = "pinyin")
//            })
//    private String title;//标讯标题

    //@Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer="ik_smart")
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
    private String title;//标讯标题

    @Field(type = FieldType.Text, analyzer = "pinyin", searchAnalyzer = "pinyin")
    private String titlePinYin;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
    private String projectName;//项目名称

    @Field(type = FieldType.Keyword)
    private String projectCode;//项目编号

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date projectDate;//项目公告日期

    @Field(type = FieldType.Text, index = false)
    private String expert;//评审专家

    @Field(type = FieldType.Keyword)
    private String purchaseTypeName;//采购方式名称

    @Field(type = FieldType.Keyword)
    private String announcementTypeName;//公告类型名称

    @Field(type = FieldType.Keyword)
    private String purchaserName;//采购人分类名称

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
    private String projectInfo;//项目简介

    @Field(type = FieldType.Long)
    private Long bidMoney;//标的金额

    @Field(type = FieldType.Keyword)
    private String province;//省名称

    @Field(type = FieldType.Keyword)
    private String city;//市名称

    @Field(type = FieldType.Keyword)
    private String town;//区

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
    private String fullArea;//省市区的全部名称

    @Field(type = FieldType.Keyword)
    private String subcontract;//分包情况

    @Field(type = FieldType.Long)
    private Long budgetMoney;//预算金额

    @Field(type = FieldType.Text, index = false)//pageUrl不做全文检索
    private String pageUrl;

    @Field(type = FieldType.Text, index = false)//中标单位不做全文检索
    private String winningBidder;//中标单位

    @Field(type = FieldType.Long, index = false)//不做全文检索字段
    private Long contentId;//bid_content表主键id

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
    private String pureContent;

    @Field(type = FieldType.Text, index = false, store = false)//带html标签的content不保存，不索引
    //@Field(type=FieldType.Text, index = false)//带html标签的content不索引
    private String content;


    /**
     * 采购单位名称
     */
    @Field(type = FieldType.Text, index = false)
    private String companyName;

    /**
     * 采购单位联系人
     */
    @Field(type = FieldType.Text, index = false)
    private String companyContact;

    /**
     * 采购单位地址
     */
    @Field(type = FieldType.Text, index = false)
    private String companyAddress;


    /**
     * 采购单位联系电话
     */
    @Field(type = FieldType.Text, index = false)
    private String companyTel;

    /**
     * 代理机构名称
     */
    @Field(type = FieldType.Text, index = false)
    private String agencyName;

    /**
     * 代理机构联系人
     */
    @Field(type = FieldType.Text, index = false)
    private String agencyContact;

    /**
     * 代理机构地址
     */
    @Field(type = FieldType.Text, index = false)
    private String agencyAddress;

    /**
     * 代理机构联系电话
     */
    @Field(type = FieldType.Text, index = false)
    private String agencyTel;

    /**
     * 标的物
     */
    @Field(type = FieldType.Text, index = false)
    private String subject;

    @Field(type = FieldType.Object)
    private List<ItemVO> esItemAis;//品目类型list对象


    /**
     * 品牌
     */
    @Field(type = FieldType.Text, index = false)
    private String brand;

    /**
     * 产品类型
     */
    @Field(type = FieldType.Text, index = false)
    private String productType;

    /**
     * 细分市场
     */
    @Field(type = FieldType.Text, index = false)
    private String marketSegments;


    @Field(type = FieldType.Text, index = false)
    private String getBidDocTime;//获取招标文件时间

    @Field(type = FieldType.Text, index = false)//pageUrl不做全文检索
    private String getBidDocAddress;//获取招标文件地点

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date bidOpeningTime;//开标时间

    @Field(type = FieldType.Text, index = false)
    private String bidOpeningAddress;//开标地点

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date bidEndTime;//投标截止日期

    @Field(type = FieldType.Text, index = false)
    private String projectId;//中国政府采购网采购意向id

    @Field(type = FieldType.Text, index = false)
    private String estimatedPurchaseTime;//预计采购时间

    @Field(type = FieldType.Long, index = false)
    private Integer exceptionStatus;//标讯数据异常状态，0正常，1金额或地区的数据异常，2金额和地区的数据都异常

    @Field(type = FieldType.Text, index = false)
    private String intentionOfProject;//项目所在采购意向

    @Field(type = FieldType.Long, index = false)
    private Integer itemFromCCGP;//品目是否从中国政府采购网采集，0不是，1是

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date winDate;//中标日期

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date changeDate;//标讯更正日期

    @Field(type = FieldType.Long, index = false)
    private Integer isModify;//是否手动修改过  1修改过 0未修改过

    private Integer isAttention = 0;//是否关注/收藏，0未关注/收藏1，1已关注/收藏

    private List<BidVO> relativeBidList;//相关标讯


    public EsBid() {
    }

    public EsBid(String id) {
        this.id = id;
    }

}
